﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace TCC.ControleFluxoDeCaixa.Apresentacao.ResourcesDictionaries.Converters
{
    public class BoolToStringConverter : IValueConverter
    {
        [ConstructorArgument("ValorNulo")]
        public string NullValue { get; set; }
        [ConstructorArgument("ValorFalso")]
        public string FalseValue { get; set; }
        [ConstructorArgument("ValorVerdadeiro")]
        public string TrueValue { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value == null ? NullValue : ((bool?) value == true ? TrueValue : FalseValue);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value == null ? null : (bool?)(value.Equals(TrueValue));
        }
    }
}